package com.derbysoft.lowcostadapter.commons.repository.impl;

import com.derbysoft.lowcostadapter.commons.model.User;
import com.derbysoft.lowcostadapter.commons.repository.UserRepository;
import org.apache.commons.lang.Validate;
import org.hibernate.Hibernate;
import org.springframework.stereotype.Repository;

@Repository("userRepository")
public class UserRepositoryImpl extends CommonService<User> implements UserRepository {
    @Override
    public User findByName(final String name) {
        Validate.notEmpty(name);
        User user = load("name", name);
        Hibernate.initialize(user.getRoles());
        return user;
    }
}